1. Field of the Invention
The present invention relates to a character sequence drawing apparatus. More particularly, the present invention relates to a character sequence drawing apparatus that draws a character sequence or executes a process related to character sequence drawing in response to a request from an application program.
2. Description of Related Art
Recently, as font-related techniques have developed, outline fonts that draw characters of any size with high quality or the like have been provided, as well as bitmap fonts. Also, various fonts or typefaces have been provided. Corresponding to the development of such fonts, Digital TVs, personal computers, printers or the like provide functions for drawing characters with various expressions using various fonts.
Conventionally, in personal computers or the like, operating systems (OS) provide application programs (AP) with character sequence drawing functions. When an AP requests a character sequence drawing specifying a character sequence and a font, an OS accesses font data corresponding to the requested font, obtains a glyph image, namely a dot pattern (hereinafter called a font pattern) of each character in the requested character sequence, and draws the font pattern on a screen. It should be noted here that the font data is information necessary for using a font and contains, for example, information indicating shapes of glyphs.
Conventional OSs can obtain a font pattern by accessing font data having a specific data format, or a specific data structure. Accordingly, when a piece of font data is to be used by an OS, the piece of font data needs to have a specific data structure that can be accessed by the OS.
In contrast, a character sequence outputting apparatus that can deal with a plurality of pieces of font data having any data structures has been disclosed (Japanese Laid-Open Patent No. 6-110888), which is intended to increase flexibility in creation of font data.
The character sequence outputting apparatus corresponds to a character sequence drawing function of conventional OS. The character sequence outputting apparatus includes a table that corresponds fonts with pieces of font data and font pattern expansion programs that expand the pieces of font data to create font patterns. Upon receipt of a character output instruction from outside, the character sequence outputting apparatus refers to the table to identify a font pattern expansion program and a piece of font data corresponding to a font specified in the instruction, generates a font pattern from the identified piece of font data using the identified font pattern expansion program, and sends the generated font pattern to a drawing apparatus, allowing the drawing apparatus to draw the font pattern.
Meanwhile, some fonts are proportional fonts in which each character has a different width. In case an AP can recognize, in drawing a character sequence using a proportional font, the width of each character and use the width for character decoration or in controlling the drawing of the background, the characters can be expressed with more variety.
In outline fonts, outline information used for forming a character, such as coordinates of lines constituting the character, needs to be rasterized to create a drawing font pattern. The drawing speed will be increased if the rasterizing can be done by a rasterizer, a hardware unit.
As described above, OSs are required to have functions for using various fonts in response to their characteristics.
The above character sequence outputting apparatus, however, can only generate font patterns from the font data, and does not have enough functions such as obtaining character width or controlling a rasterizer.
It is therefore an object of the present invention to provide a character sequence drawing apparatus that draws a character sequence with font data of any data structure and also executes various processes to make effective use of fonts in accordance with the characteristics of the fonts or the like.
The above object is fulfilled by a character sequence drawing apparatus comprising: a storage unit operable to store a plurality of pieces of font data and a plurality of font processing functions for using the plurality of pieces of font data; a font access information obtaining unit operable to obtain a piece of font access information which includes a group of addresses of font processing functions, from an application program; a request receiving unit operable to receive from the application program a request which is related to drawing of a character sequence; and a font processing function executing unit operable to identify one or more addresses of font processing functions which have been predetermined with correspondence to the received request among the group of addresses of font processing functions included in the piece of font access information, and respond to the received request by executing one or more font processing functions corresponding to the one or more addresses.
With the above construction, when the AP specifies a piece of font access information that includes a plurality of addresses of a plurality of font processing functions including a font pattern obtaining function, the character sequence drawing apparatus executes various processes (e.g., obtaining width of the character sequence) concerning the drawing of the character sequence in response to requests from the AP, using font processing functions whose locations are identified by the addresses. To make effective use of fonts, various font processing functions are used to execute processes related to the fonts by accessing the font data or the like. Since the AP can specify addresses of the font processing functions, the character sequence drawing apparatus can execute various font processing functions in accordance with requests from the AP. With this construction, the character sequence drawing apparatus need not determine a font processing function it should use in accordance with a font requested by the AP.
In the above character sequence drawing apparatus, the plurality of font processing functions may be classified into a plurality of function types, the storage unit may store one or more font processing functions for each of the plurality of function types, the piece of font access information may include one address for each of the plurality of function types, the font access information obtaining unit, for each obtainment of a piece of font access information, assigns a font ID to each obtained piece of font access information, holds the assigned font IDs and pieces of obtained font access information, and sends each font ID to the application program, wherein the font IDs correspond to the pieces of font access information on a one-to-one basis, the request receiving unit receives a font ID together with a request from the application program, and the font processing function executing unit identifies one or more addresses of font processing functions which have been predetermined with correspondence to the received request among a group of addresses of font processing functions included in a piece of font access information corresponding to the obtained font ID, and respond to the received request by executing one or more font processing functions corresponding to the one or more addresses.
With the above construction, when the AP sends a request related to drawing of a character sequence with specification of a font ID, the character sequence drawing apparatus executes one or more font processing functions corresponding to the specified font ID in response to the request. With this construction, the AP can specify a different font ID for each character sequence to allow the character sequence drawing apparatus to draw each character sequence with a different font.
In the above character sequence drawing apparatus, the storage unit may store one or more font pattern obtaining functions which are classified as a function type and each identify a font pattern based on a piece of font data and obtain the identified font pattern, each piece of font access information includes an address of a font pattern obtaining function in the storage unit, and when the request receiving unit receives a request to draw a character sequence, the font processing function executing unit draws the character sequence by identifying an address of a font pattern obtaining function based on the received request among a group of addresses of font processing functions included in a piece of font access information corresponding to the obtained font ID and executing the font pattern obtaining function corresponding to the identified address to obtain font patterns of characters included in the character sequence.
With the above construction, the AP previously sends a piece of font access information including an address of a font pattern obtaining function corresponding to a piece of font data regardless of the data structure of the piece of font data, and later sends a character sequence drawing request to the character sequence drawing apparatus so that the character sequence drawing apparatus can execute the font pattern obtaining function to obtain a font pattern, and draw the character sequence using a specific font.
In the above character sequence drawing apparatus, each piece of font data may contain common font metrics information that shows attributes common to a plurality of glyphs, two attributes among the attributes being an ascent and a descent, the storage unit stores one or more common font metrics information obtaining functions which are classified as a function type and each obtain common font metrics information by accessing a piece of font data, each piece of font access information includes an address of a common font metrics information obtaining function in the storage unit, and the font processing function executing unit identifies an address of a common font metrics information obtaining function based on the received request among a group of addresses of font processing functions included in a piece of font access information corresponding to the obtained font ID and executes the common font metrics information obtaining function.
With the above construction, the AP previously sends a piece of font access information including an address of a common font metrics information obtaining function corresponding to a piece of font data regardless of the data structure of the piece of font data, and later requests the character sequence drawing apparatus to return a height of the font or the like so that the character sequence drawing apparatus can execute the common font metrics information obtaining function to obtain attributes (e.g. an ascent and a descent) common to the glyphs of a specific font, obtain the height of the font or the like based on the attributes, and send the obtained height or the like to the AP.
In the above character sequence drawing apparatus, when the request receiving unit receives a request to obtain a height of a font, the font processing function executing unit may obtain the ascent and the descent by executing the common font metrics information obtaining function, calculates the height of the font based on the ascent and the descent, and sends a result of the calculation to the application program.
With the above construction, the AP can obtain the height of the font, and, for example, can adjust the distance between lines in the character sequence, based on the obtained height.
In the above character sequence drawing apparatus, each piece of font data may contain glyph-by-glyph font metrics information that shows attributes unique to the plurality of glyphs, wherein one of the attributes is a glyph width, the storage unit stores one or more glyph-by-glyph font metrics information obtaining functions which are classified as a function type and each obtain a glyph-by-glyph font metrics information by accessing a piece of font data, each piece of font access information includes address information which is either an address of a glyph-by-glyph font metrics information obtaining function in the storage unit or null values, and when it is possible for the font processing function executing unit to obtain an address of a glyph-by-glyph font metrics information obtaining function based on the received request among a group of addresses of font processing functions included in a piece of font access information corresponding to the obtained font ID, the font processing function executing unit executes the glyph-by-glyph font metrics information obtaining function corresponding to the obtained address.
With the above construction, when the AP intends to use a font that has a different characteristic for each glyph, such as a proportional font, the AP previously sends a piece of font access information including an address of a glyph-by-glyph font metrics information obtaining function corresponding to a piece of font data of the above font regardless of the data structure of the piece of font data, and later requests the character sequence drawing apparatus to return a width of the font or the like so that the character sequence drawing apparatus can execute the glyph-by-glyph font metrics information obtaining function to obtain information such as widths of the glyphs, obtain the width of the character sequence or the like based on the information, and send the obtained width or the like to the AP.
In the above character sequence drawing apparatus, one of the attributes shown by the common font metrics information may be an average width of the plurality of glyphs, when the request receiving unit receives a request to obtain a width of the character sequence, the font processing function executing unit judges whether the address information of the glyph-by-glyph font metrics information obtaining function in the font access information corresponding to the font ID obtained by the request receiving unit is the null values or not, when the address information is the null values, the font processing function executing unit executes the common font metrics information to obtain an average width of the plurality of glyphs, calculates a width of the character sequence based on the average width, and sends a result of the calculation to the application program, and when the address information is not the null values, the font processing function executing unit executes the glyph-by-glyph font metrics information obtaining function to obtain glyph widths of characters included in the character sequence, calculates a width of the character sequence based on the obtained glyph widths, and sends a result of the calculation to the application program.
With the above construction, when the AP intends to use a proportional font, the AP previously sends a piece of font access information in which an address of a glyph-by-glyph font metrics information obtaining function is set as the address information; and when the AP intends to use a fixed-pitch font, the AP previously sends a piece of font access information in which null values are set as the address information. The AP later requests the character sequence drawing apparatus to return a width of the character sequence, obtains the width from the character sequence drawing apparatus, and determine a range of drawing based on the obtained width.
In the above character sequence drawing apparatus, the storage unit may store one or more character code conversion functions which are classified as a function type and each output one or more internal codes corresponding to one or more input character codes, each font pattern obtaining function outputs a font pattern of a glyph which is identified when one of the one or more internal codes is input, each piece of font access information includes an address of a character code conversion function in the storage unit, when the request receiving unit receives a request to draw a character sequence, the font processing function executing unit obtains from the application program one or more character codes that represent a drawing-object character sequence, obtains one or more internal codes by executing a character code conversion function using the one or more character codes, and obtains a font pattern for each character included in the drawing-object character sequence by executing a font pattern obtaining function using each of the one or more internal codes.
With the above construction, the character sequence drawing apparatus does not receive character codes, but receives internal codes with which the apparatus can access font data at high speed. The character sequence drawing apparatus executes the font pattern obtaining function using the internal codes. This increases the possibility of speeding up the drawing of the character sequence.
In the above character sequence drawing apparatus, each piece of font access information may include an address of a piece of font data in the storage unit, each font pattern obtaining function identifies a font pattern based on a piece of font data that is identified by an input address of the piece of font data, and when the request receiving unit receives a request to draw a character sequence, the font processing function executing unit draws the character sequence by obtaining an address of a piece of font data from a piece of font access information corresponding to the obtained font ID based on the received request, and executing a font pattern obtaining function using the address of the piece of font data.
With the above construction, the font pattern obtaining function is not dedicated to a specific piece of font data, and can be used for accessing a plurality of pieces of font data. When the AP intends to use fonts A and B having font data with the same data structure, the AP previously sends a piece of font access information twice by changing only the font data address, and later requests the character sequence drawing apparatus to draw a character sequence with either font A or font B as necessary. With this sharing of the font pattern obtaining function, the storage unit is required to store a smaller amount of data than the case where a font pattern obtaining function is required for each piece of font data.
In the above character sequence drawing apparatus, the storage unit may store one or more initialization functions which are classified as a function type and each initialize a rasterizer that generates a font pattern based on a piece of font data, each piece of font access information includes address information which is either an address of an initialization function in the storage unit or null values, and when it is possible for the font processing function executing unit to obtain an address of an initialization function based on the received request from a piece of font access information corresponding to the obtained font ID, the font processing function executing unit executes an initialization function corresponding to the obtained address.
With the above construction, the AP sends a piece of font access information including an address of an initialization function to the character sequence drawing apparatus, so that the rasterizer is initialized with correspondence to the piece of font data.
In the above character sequence drawing apparatus, when the font access information obtaining unit obtains a piece of font access information, the font processing function executing unit may judge whether address information of initialization function in the obtained piece of font access information is the null values or not, when the address information is not the null values, the font processing function executing unit initializes the rasterizer by executing the initialization function.
With the above construction, when the AP intends to use a font that requires the rasterizer to use the font pattern, the AP previously sends a piece of font access information in which an address of an initialization function is set as the address information; and when the AP intends to use a font (e.g., a bitmap font) that does not require the rasterizer to use the font pattern, the AP previously sends a piece of font access information in which null values are set as the address information. This allows the rasterizer to be initialized as necessary. When the AP sends a piece of font access information in which an address of an initialization function is set as the address information to the character sequence drawing apparatus, the rasterizer being hardware is initialized. This eliminates the necessity of initialization of the rasterizer when the AP requests to draw a character sequence later. As a result, character sequences are drawn at high speed.
In the above character sequence drawing apparatus, the piece of font access information may include address information for each of the plurality of font processing functions, the address information being either an address of a corresponding font processing function in the storage unit or null values, and when address information of a font processing function included in a piece of font access information corresponding to the font ID obtained by the request receiving unit is not the null values, the font processing function executing unit executes the font processing function.
With the above construction, the AP can select font processing functions for each font by setting the address information of unnecessary font processing functions to null values. When, later, the AP sends a request to execute a process related to drawing of the character sequence, the character sequence drawing apparatus executes only necessary font processing functions for achieving the requested process.
The above character sequence drawing apparatus may further comprise: a reading unit operable to obtain font data and a font processing function from outside and store the obtained font data and the obtained font processing function in the storage unit; and an address managing unit operable to, upon receipt of a request from an application program, send an address of the font data or the font processing function to the application program.
With the above construction, even when font data and font processing functions are obtained from outside instead of being stored previously, the AP can obtain addresses of the font data and font processing functions and send a piece of font access information including one of the obtained addresses to the character sequence drawing apparatus, the address specifying a font processing function necessary for using a desired font.
The above object is also fulfilled by a character sequence drawing method which uses a plurality of pieces of font data and a plurality of font processing functions for using the plurality of pieces of font data, the character sequence drawing method comprising: a font access information obtaining step for obtaining a piece of font access information which includes a group of addresses of font processing functions, from an application program; a request receiving step for receiving from the application program a request which is related to drawing of a character sequence; and a font processing function executing step for identifying one or more addresses of font processing which have been predetermined with correspondence to the received request among the group of addresses of font processing functions included in the piece of font access information, and responding to the received request by executing one or more font processing functions corresponding to the one or more addresses. With the above construction, when the AP specifies a piece of font access information that includes a plurality of addresses of a plurality of font processing functions including a font pattern obtaining function, the character sequence drawing apparatus executes various processes (e.g., obtaining width of the character sequence) concerning the drawing of the character sequence in response to requests from the AP, using font processing functions whose locations are identified by the addresses.